package miage.rest.test;

import java.io.FileOutputStream;
import org.apache.commons.dbcp.BasicDataSource;
import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSet;

/**
 *
 * @author Schwartz Michaël
 */
public class DatabaseExport {

	public static void main(String[] args) throws Exception {

		BasicDataSource ds = new BasicDataSource();
		Configuration config = new Configuration();

		ds.setDriverClassName(config.getDbDriverClassName());
		ds.setUrl(config.getDbUrl());
		ds.setUsername(config.getDbUser());
		ds.setPassword(config.getDbPassword());

		IDatabaseConnection connection = new DatabaseConnection(ds.getConnection());

		IDataSet fullDataSet = connection.createDataSet();
		FlatXmlDataSet.write(fullDataSet, new FileOutputStream("data/database.xml"));

	}
}
